<!DOCTYPE html>
<html lang="zh-cmn-Hans">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
	<meta name="format-detection" content="telephone=no, date=no, address=no, email=no, url=no">
	<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
	<meta http-equiv="Pragma" content="no-cache">
	<meta http-equiv="Expires" content="0">
	<title>退换处理</title>
	<meta name="description" content="">	
	<script type="text/javascript">
		(function (win, doc) {
			if (!win.addEventListener) return;
			var html = document.documentElement;
			function setFont() {
				var cliWidth = html.clientWidth;
				html.style.fontSize = 100 * (cliWidth / 750) + 'px';
			}
			win.addEventListener('resize', setFont, false);
			setFont();
		})(window, document);
	</script>
	<link rel="stylesheet" href="__WECHATCSS__/admin/css/main.css?201812201156">
</head>

<body>
	<div class="header">
        <img class="wecharHead" src="{$member_info.headimgurl}" />
        <h2>您好，{$member_info.nickname}</h2>
        <h3>所属门店：{$storeAdminInfo.store_name}</h3>
		<h3>金额：￥{$saAccountInfo.paied_amount}</h3>
        <p>
			<span>库存：</span>
			{volist name='goodsStoreList' id='item'}
				<span>{$item.goods_name}：{$item.store_count}</span>				
			{/volist}
		</p> 
		<p>
			<span>已借出：</span>
			{volist name='goodsStoreList' id='item'}
			{if condition="$item.sale_mode == 1 || $item.sale_mode == 2 "}
				<span>{$item.goods_name}：{$item.hire_sum}</span>	
			{/if}			
			{/volist}
		</p>
		<p>
			<span>已卖出：</span>
			{volist name='goodsStoreList' id='item'}
			{if condition="$item.sale_mode == 0 || $item.sale_mode == 2 "}
				<span>{$item.goods_name}：{$item.sales_sum}</span>		
			{/if}						
			{/volist}
		</p>
    </div>
	<div class="content">
		<div class="search">
			<form method="POST">
				<input type="text" name="keyword" placeholder="请输入订单号" class="s_input">
				<input type="submit" value="搜索" class="s_btn">
			</form>
		</div>
		<ul class="returnList">
			{volist name="list" id="v"}				
            <li>
                <p>订单号：{$v.order_sn}</p>
                <p>申请时间：{if condition="$v.order_status == 4 && $v.hire_status == 3"}{$v['apply_time']|date="Y-m-d H:i:s",###}{/if}</p>
                <p>桌号：{$v.seat_num}</p>
                <p>金额：￥{$v.total_amount}</p>
				{if condition="$v.order_status == 2 && $v.pay_status == 1 && $v.shipping_status == 0 "}
				<div class="center">
					<span class="btn" data-click="j_send" data-id="{$v.order_id}">发货</span>
				</div>
				{/if}
				{if condition="$v.order_status == 3 && $v.pay_status == 1 && $v.shipping_status == 1 "}
				<div class="center">
					<span class="btn" data-click="j_Sign" data-id="{$v.order_id}">客户签收</span>
				</div>
				{/if}
				{if condition="$v.order_mode == 1 && $v.order_status == 4 && $v.hire_status == 3 && $v.audit_status == 0"}
				<div class="center">
					<span class="btn" data-click="j_refund" data-id="{$v.order_id}">退还押金</span>
					<a class="btn"  href="{:Url('StoreAdmin/rejectorder',['order_id'=>$v.order_id])}">拒绝退还</a>
				</div>
				{/if}
				{if condition="$v.order_mode == 1 && $v.order_status == 4 && $v.hire_status == 4 && $v.audit_status == 1 && $v.refund_status == 1"}
				<div class="center">
					<span class="btn" data-click="j_refundOk" data-id="{$v.order_id}">退款</span>
				<div>
				{/if}
				{if condition="$v.order_mode == 1 && $v.order_status == 4 && $v.hire_status == 3 && $v.audit_status == 2"}
				<span class="set ing">已拒绝</span>
				{/if}
				{if condition="$v.order_mode == 1 && $v.order_status == 5 && $v.hire_status == 4 && $v.audit_status == 1"}
				<span class="set ed">已退还</span>
				{/if}
				{if condition="$v.order_mode == 1 && $v.order_status == 5 && $v.hire_status == 5 && $v.audit_status == 1"}
				<span class="set ed">已退款</span>
				{/if}
				{if condition="$v.order_mode == 1 && $v.order_status == 5 && $v.hire_status == 6 && $v.audit_status == 1"}
				<span class="set ed">已售出</span>
				{/if}
            </li>            
			{/volist}
        </ul>
		<span class="loadMore" data-page="1" data-url="/index.php/wechat/store_admin/returns_index.html?page=">加载更多</span>
	</div>
	<script src="__WECHATASSETS__/jquery.min.js"></script>
	<script>
		$('body').on('touchstart','span.btn',function(){
			$('body').append('<div class="loading"><div class="mask"></div><div class="load-txt">退款中</div></div>');
			var clickType=$(this).attr('data-click'),vid=$(this).attr('data-id'),url='';
			switch(clickType){
				case 'j_refund':
					url = "{:Url('StoreAdmin/refundorder')}";
				break;
				case 'j_send':
					url = "{:Url('StoreAdmin/order_shipping')}";
				break;
				case 'j_Sign':
					url = "{:Url('StoreAdmin/order_sign')}";
				break;
				case 'j_refundOk':
					url = "{:Url('StoreAdmin/order_refund')}";
				break;
				default:
				alert('非法操作');
				return;				
			}
			if(url.length>0){
				$.ajax({
					url: url,
					data: { order_id: vid },
					type: "post",
					dataType: "json",
					success: function (res) {
						alert(res.msg);
						if (parseInt(res.status) > 0) {
							window.location = window.location.href.replace('#','');
						}
					}
				});
			}

		});
		if($('.returnList li').length<10){
			$('.loadMore').remove();
		}
		$('.loadMore').on('touchstart',function(){
			var nextPage=parseInt($(this).attr('data-page'))+1,url=$(this).attr('data-url');
			$.ajax({
				url: url+nextPage,
				cache: false,
				success: function (data){
					var dom = $('<div>').append(data);
                    var $list = dom.find('.returnList');
					if($list.find('li').length>0){
						$('.returnList').append($list.html());
						if($list.find('li').length<10){
							$('.loadMore').remove();
						}else{
							$('.loadMore').attr('data-page',nextPage);
						}
					}else{
						$('.loadMore').remove();
					}
				}
			});
		});
	</script>
</body>

</html>